<template>
    <div>
        <div class="recommend">
            <div class="recommend-items" v-for="item in recommends.slice(0,4)" :key="item.id">
                <a href="" @click.prevent="goDetail(item.id)" >
                    <img v-lazy="item.cover_url"  alt=""/>
                    <div>{{item.title}}</div>
                </a>
            </div>
        </div>
    </div>
</template>

<script>
    import {useRouter} from 'vue-router'
    export default {
        name: "RecommendView",
        setup(){
            const router =useRouter();
            const goDetail =(id) =>{
                router.push({path:'/detail',query:{id}})
            }
            return{
                goDetail
            }
        },
        props:{
            recommends:{
                type:Array,
                default(){
                    return[];
                }
            }
        }
    }
</script>

<style scoped>
.recommend{
    display: flex;
    padding: 15px;
    width: 100%;
    text-align: center;
    border-bottom: 8px solid #EEE;
    font-size: 12px;

}
    .recommend-items{
        flex: 1;
        margin: 5px;

    }
    .recommend-items>a>img{
        height: 70px;
        width: 70px;
    }
</style>